home *** CD-ROM | disk | FTP | other *** search
- on initVars
- global gDefaultLinearList, gDefaultPropList, aVariableName, aVar1, aVar2
- set aVariableName to "apple"
- set aVar1 to 100
- set aVar2 to 200
- set gDefaultLinearList to ["this", "that", "the other thing", aVariableName, 123.40000000000000568, "more text"]
- set gDefaultPropList to [#propertyNameA: 1, #c: 5, #b: "applesauce", "a string": "another string"]
- end
-
- on buildList pCandidateList, pTypeOfList
- global gDefaultLinearList, gDefaultPropList
- set vValidList to 0
- cursor(4)
- set vValidList to checkList(pCandidateList, pTypeOfList)
- if vValidList = 1 then
- case pTypeOfList of
- #linearList:
- set vNewList to value(the text of member "Building Input Field")
- set gDefaultLinearList to vNewList
- set the text of member "Building Display Field 1" to string(gDefaultLinearList)
- #propList:
- set vNewList to value(the text of member "Building Input Field")
- set gDefaultPropList to vNewList
- set the text of member "Building Display Field 1" to string(gDefaultPropList)
- end case
- end if
- cursor(-1)
- end
-
- on checkList pCandidateList, pTypeOfList
- set vValidList to 0
- case 1 of
- ilk(value(pCandidateList), pTypeOfList):
- set vValidList to 1
- (listp(value(pCandidateList)) and not ilk(value(pCandidateList), pTypeOfList)):
- displayError("<valid list wrong type>")
- (char 1 of stripSpaces(pCandidateList) <> "["):
- displayError("< when building Lists: Illegal Brackets>")
- (the last char in stripSpaces(pCandidateList) <> "]"):
- displayError("< when building Lists: Illegal Brackets>")
- checkBadList(pCandidateList, pTypeOfList):
- otherwise:
- displayError("<undefined error>")
- end case
- return vValidList
- end
-
- on checkBadList pCandidateList, pTypeOfList
- set vFoundError to 0
- set pCandidateList to stripSpaces(pCandidateList)
- delete char 1 of pCandidateList
- delete char -30000 of pCandidateList
- set vLastItemNumber to the number of items in pCandidateList
- repeat with m = 1 to vLastItemNumber
- set vCurrentItem to item m of pCandidateList
- case pTypeOfList of
- #linearList:
- if checkItem(vCurrentItem) then
- set vFoundError to 0
- else
- set vFoundError to 1
- end if
- #propList:
- if vCurrentItem contains ":" then
- set the itemDelimiter to ":"
- set vItem1 to item 1 of vCurrentItem
- set vItem2 to item 2 of vCurrentItem
- set the itemDelimiter to ","
- if checkItem(vItem1) and checkItem(vItem2) then
- set vFoundError to 0
- else
- set vFoundError to 1
- end if
- else
- set vValidList to 0
- end if
- end case
- if vFoundError = 1 then
- exit repeat
- end if
- end repeat
- return vFoundError
- end
-
- on checkItem vCurrentItem
- set vValidItem to 0
- set vCurrentItem to stripSpaces(vCurrentItem)
- case 1 of
- ((vCurrentItem starts QUOTE) and (the last char in vCurrentItem = QUOTE)):
- set vValidItem to 1
- (vCurrentItem = EMPTY):
- set vValidItem to 0
- (vCurrentItem contains " "):
- set vValidItem to 0
- (vCurrentItem contains ":"):
- set vValidItem to 0
- (vCurrentItem contains RETURN):
- set vValidItem to 0
- (vCurrentItem contains "["):
- set vValidItem to 0
- (vCurrentItem contains "]"):
- set vValidItem to 0
- otherwise:
- set vValidItem to 1
- end case
- if vValidItem = 0 then
- displayError("<bad item>")
- end if
- return vValidItem
- end
-
- on checkPosition whichNumber, whatListLength
- set whichNumber to stripSpaces(whichNumber)
- case 1 of
- voidp(value(whichNumber)):
- displayError("< Illegal values of getAt position>")
- set whichNumber to EMPTY
- (not integerp(value(whichNumber))):
- displayError("<For bad numbers>")
- set whichNumber to EMPTY
- (value(whichNumber) < 1):
- displayError("<Greater than zero>")
- set whichNumber to EMPTY
- (whatListLength = EMPTY):
- set whichNumber to value(whichNumber)
- (value(whichNumber) > whatListLength):
- displayError("<Index Out of Range>")
- set whichNumber to EMPTY
- otherwise:
- set whichNumber to value(whichNumber)
- end case
- return whichNumber
- end
-
- on checkValue whichValue
- set whichValue to stripSpaces(whichValue)
- case 1 of
- ((char 1 of whichValue = QUOTE) and (the last char in whichValue = QUOTE)):
- set whichValue to stripQuotes(whichValue)
- voidp(value(whichValue)):
- displayError("<no quotes>")
- set whichValue to EMPTY
- (not voidp(value(whichValue))):
- case 1 of
- symbolp(value(whichValue)):
- case 1 of
- (whichValue contains ":"):
- displayError("<symbols no colons>")
- set whichValue to EMPTY
- (whichValue contains " "):
- displayError("<symbols no spaces>")
- set whichValue to EMPTY
- otherwise:
- set whichValue to value(whichValue)
- end case
- integerp(value(whichValue)):
- set whichValue to value(whichValue)
- floatp(value(whichValue)):
- set whichValue to value(whichValue)
- end case
- otherwise:
- set whichValue to EMPTY
- end case
- return whichValue
- end
-
- on stripSpaces pTextString
- if stringp(pTextString) then
- set vItemSize to the number of chars in pTextString
- repeat with r = 1 to vItemSize
- if char 1 of pTextString = " " then
- delete char 1 of pTextString
- end if
- end repeat
- set vItemSize to the number of chars in pTextString
- repeat with r = 1 to vItemSize
- if the last char in pTextString = " " then
- delete char -30000 of pTextString
- end if
- end repeat
- end if
- return pTextString
- end
-
- on stripQuotes whichString
- if char 1 of whichString = QUOTE then
- delete char 1 of whichString
- end if
- if the last char in whichString = QUOTE then
- delete char -30000 of whichString
- end if
- return whichString
- end
-